﻿using System;
using System.ComponentModel;
using System.Runtime.InteropServices;

namespace Teigha.Core
{
	public class OdGiCommonDraw : OdRxObject
	{
		[EditorBrowsable(EditorBrowsableState.Never)]
		public OdGiCommonDraw(IntPtr cPtr, bool cMemoryOwn) : base(GlobalsPINVOKE.OdGiCommonDraw_SWIGUpcast(cPtr), cMemoryOwn)
		{
			this.swigCPtr = new HandleRef(this, cPtr);
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		public static HandleRef getCPtr(OdGiCommonDraw obj)
		{
			if (obj != null)
			{
				return obj.swigCPtr;
			}
			return new HandleRef(null, IntPtr.Zero);
		}

		~OdGiCommonDraw()
		{
			this.Dispose();
		}

		public override void Dispose()
		{
			if (this.swigCPtr.Handle != IntPtr.Zero)
			{
				if (this.swigCMemOwn)
				{
					lock (this.locker)
					{
						if (this.swigCPtr.Handle != IntPtr.Zero && this.swigCMemOwn)
						{
							this.swigCMemOwn = false;
							GlobalsPINVOKE.delete_OdGiCommonDraw(this.swigCPtr);
						}
					}
					this.swigCMemOwn = false;
				}
				this.swigCPtr = new HandleRef(null, IntPtr.Zero);
			}
			GC.SuppressFinalize(this);
			base.Dispose();
		}

		public new static OdGiCommonDraw cast(OdRxObject pObj)
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = GlobalsPINVOKE.OdGiCommonDraw_cast(OdRxObject.getCPtr(pObj));
			OdGiCommonDraw result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdGiCommonDraw)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdGiCommonDraw)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdGiCommonDraw)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new static OdRxClass desc()
		{
			OdRxClass result = (OdRxClass)Teigha.Core.Helpers.odrxCreateObjectInternal(GlobalsPINVOKE.OdGiCommonDraw_desc(), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual OdRxClass isA()
		{
			OdRxClass result = (OdRxClass)Teigha.Core.Helpers.odrxCreateObjectInternal(GlobalsPINVOKE.OdGiCommonDraw_isA(this.swigCPtr), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual OdRxObject queryX(OdRxClass protocolClass)
		{
			OdRxObject result = Teigha.Core.Helpers.odrxCreateObjectInternal(GlobalsPINVOKE.OdGiCommonDraw_queryX(this.swigCPtr, OdRxClass.getCPtr(protocolClass)), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public static OdGiCommonDraw createObject()
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = GlobalsPINVOKE.OdGiCommonDraw_createObject();
			OdGiCommonDraw result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdGiCommonDraw)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdGiCommonDraw)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdGiCommonDraw)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdGiRegenType regenType()
		{
			OdGiRegenType result = (OdGiRegenType)GlobalsPINVOKE.OdGiCommonDraw_regenType(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual bool regenAbort()
		{
			bool result = GlobalsPINVOKE.OdGiCommonDraw_regenAbort(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdGiSubEntityTraits subEntityTraits()
		{
			OdGiSubEntityTraits result = (OdGiSubEntityTraits)Teigha.Core.Helpers.odrxCreateObjectInternal(GlobalsPINVOKE.OdGiCommonDraw_subEntityTraits(this.swigCPtr), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdGiGeometry rawGeometry()
		{
			OdGiGeometry result = (OdGiGeometry)Teigha.Core.Helpers.odrxCreateObjectInternal(GlobalsPINVOKE.OdGiCommonDraw_rawGeometry(this.swigCPtr), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual bool isDragging()
		{
			bool result = GlobalsPINVOKE.OdGiCommonDraw_isDragging(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual double deviation(OdGiDeviationType deviationType, OdGePoint3d pointOnCurve)
		{
			double result = GlobalsPINVOKE.OdGiCommonDraw_deviation(this.swigCPtr, (int)deviationType, OdGePoint3d.getCPtr(pointOnCurve));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual uint numberOfIsolines()
		{
			uint result = GlobalsPINVOKE.OdGiCommonDraw_numberOfIsolines(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdGiContext context()
		{
			OdGiContext result = (OdGiContext)Teigha.Core.Helpers.odrxCreateObjectInternal(GlobalsPINVOKE.OdGiCommonDraw_context(this.swigCPtr), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdGiPathNode currentGiPath()
		{
			IntPtr intPtr = GlobalsPINVOKE.OdGiCommonDraw_currentGiPath(this.swigCPtr);
			OdGiPathNode result = (intPtr == IntPtr.Zero) ? null : new OdGiPathNode(intPtr, false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		private object locker = new object();

		private HandleRef swigCPtr;
	}
}
